(function() {

    var
    $u = juliet.using({
        func : 'juliet.core.func-0.1',
        validationResult : 'juliet.validation.validationResult-0.2',
        validationEvent : 'juliet.validation.validationEvent-0.2',
        Base : 'juliet.validation.validators.Base-0.2'
    }),
    ve = $u('validationEvent'),
    vr = $u('validationResult');

    var CustomClass = function() {

        this.defaultErrorKey = 'validation:custom';

        this.continueValidation = function(result) {
            var listItem = this.chain.validators.list[this.uid];

            this.validationCache.result = result;
            this.chain.validate({ validatorListItem : listItem, event : ve.CONTINUE });
        };

        this.validate = function(value) {
            var cache = this.validationCache;

            if (cache.value === value) {
                return;
            }

            cache.value = value;
            cache.result = vr.IN_PROGRESS;

            this.options.validateCallback.call(null, {
                value : value,
                continueValidation : $u('func').proxy(this.continueValidation, this)
            });
        };

    };

    CustomClass.prototype = new ($u('Base'))();

    juliet.registerModule('juliet.validation.validators', 'Custom-0.2', CustomClass);

})();
